home *** CD-ROM | disk | FTP | other *** search
- Path: news.nask.org.pl!usenet
- From: flssoft@blue.maloka.waw.pl (Grzegorz (FLS))
- Newsgroups: comp.lang.c++
- Subject: Re: help! getting EOF in the middle of the file!
- Date: Sat, 06 Apr 1996 16:02:11 GMT
- Organization: Research and Academic Computer Network
- Message-ID: <4k60qk$iuu@bilbo.nask.org.pl>
- References: <DpDL8o.6xs@cdf.toronto.edu>
- NNTP-Posting-Host: s113.maloka.waw.pl
- X-Newsreader: Forte Free Agent v0.46
-
- On Fri, 5 Apr 1996 06:12:22 GMT, you wrote:
-
- >I have a program that was working fine using cin, and I tried to change it so
- >it reads from a file.
-
- >It was working with the exact same data file before when I used:
- >a.out < datafile
-
- >now it doesn't work, see the code below:
-
- >int x;
- >ifstream in_stream;
-
- >// in_stream is open and I'm reading from it no problem.
- >// I'm halfway through the input file, and in_stream.eof() == 0 right now
-
- >x = in_stream.get();
-
- >// now in_stream.eof() == 1
- >// but I haven't reached the end of the file!!
-
- >What could be going wrong here? Any suggestions would be greatly appreciated.
-
- Hi Paul,
-
- It is possible, that on input you have a binary data, and you have
- opened an input as a text file. The end of text file is marked with
- char( 26 ) character, and this character could be in middle of a file.
- The binary data has no end character. A function reaches the end of
- this file when it read all data from input.
- The solution (meybe) is to open an input in a binary mode.
-
- Reagrds,
- Grzegorz.
-
-
-
- Grzegorz
-
- ``````````````````````````` Grzes vel Pysiak
- Ablue, pecte canem, canis est et permanet idem.
- Desunt cetera!
-
-